<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set> 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>审核采购表</title>

    <link rel="shortcut icon" href="${ctx}/favicon.ico"> <link href="${ctx}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${ctx}/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${ctx}/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctx}/css/animate.css" rel="stylesheet">
    <link href="${ctx}/css/style.css?v=4.1.0" rel="stylesheet">
</head>

<body>
        <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        
                        <div class="ibox-content">
                            <div class="row">
                                <div class="col-sm-3 m-b-xs">
                                    <input type="text" name="values" style="font-size:18px;margin-top:2px; " autocomplete="off"/>
                                </div>
                                <div class="col-sm-2 m-b-xs">
                                    <div data-toggle="buttons" >
                                        <div class="btn btn-sm btn-white" style="height:35px;font-size:18px;margin-left:-90px;" onclick="findLike()">
                                                &nbsp;&nbsp;查&nbsp;找&nbsp;&nbsp;
                                        </div>
                                    </div>
                                </div>
                                
                            </div>
                            <div class="table-responsive"style="height:430px;">
                                <table class="table table-striped">
                                    <thead>
	                                    <tr>
	                                        <th>商品名称</th>
	                                        <th>价格</th>
	                                        <th>规格</th>
	                                        <th>数量</th>
	                                        <th>采购人</th>
	                                        <th>厂商</th>
	                                        <th>备注</th>
	                                        <th>审核状态</th>
	                                        <th>审核</th>
	                                        <th>取消审核</th>                                      
	                                    </tr>
                                    </thead>
                                    <tbody>
                                    	<c:forEach var="purchase" items="${purchase_list}">
                                            <tr>     
                                                 <td>${purchase.goods_name}</td>
                                                 <td>${purchase.price}</td>
                                                 <td>${purchase.unit}</td>
                                                 <td>${purchase.number}</td>
                                                 <td>${purchase.purchase_name}</td>
                                                 <td>${purchase.supplier_}</td>
                                                 <td>${purchase.remark}</td>
                                                 <td id="${purchase.purchase_id}">${purchase.inspect}</td>
                                                 <td>
                                            		<a class="btn btn-primary btn-rounded" onclick="inspectInfo(${purchase.purchase_id})">审核</a>
                                        		 </td>
                                        		 <td>
                                            		<a class="btn btn-primary btn-rounded" onclick="noInspectInfo(${purchase.purchase_id})">取消审核</a>
                                        		 </td>
                                             </tr>
                                         </c:forEach>                                 
                                    </tbody>
                                </table>
                            </div>
                            <div>
                            	<!-- <span style="float:left;">共25条数据5页</span> -->
                            	<div id="page" style="text-align:right;"></div>
                            </div>       
                        </div>
                    </div>
                </div>       
        </div>
</body>
<!-- 全局js -->
<script src="${ctx}/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctx}/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${ctx}/dist/layer-v3.1.1/layer/layer.js"></script>
<script src="${ctx}/dist/jquery-bootstrap-pagination/jquery-bootstrap-pagination.js"></script>
<script type="text/javascript">
	function findLike() {
		values=$('[name=values]').val();
		location="${ctx}/PurchaseServlet/inspectInfoList?values="+values;
	}

	<c:if test="${pageCount!=null}">
		//分页
		$("#page").pagination({
		  total_pages:${pageCount},
		  current_page:${pageNum},
		  prev: "上一页",
		  next: "下一页",
		  display_max:4,
		  callback: function(event, page) {
		      //return alert("Page " + page + " was clicked!");
		      location="${ctx}/PurchaseServlet/inspectInfoList?pageNum="+page;
		}
		});  
	</c:if>

	function inspectInfo(purchase_id) {			
        	$.get('${ctx}/PurchaseServlet/inspectInfo',{'purchase_id':purchase_id},function(data){
        		if(data){
					document.getElementById(purchase_id).innerHTML='1';
					layer.msg('审核成功');	
				}else{
					layer.msg('审核失败');
				}
        	});    		
    	
	}
	
	function noInspectInfo(purchase_id) {
		$.get('${ctx}/PurchaseServlet/noInspectInfo',{'purchase_id':purchase_id},function(data){
    		if(data){
				document.getElementById(purchase_id).innerHTML='0';
				layer.msg('取消审核成功');
			}else{
				layer.msg('取消审核失败');
			}
    	}); 
	}

	history.pushState(null,null,'${ctx}/PurchaseServlet/inspectInfoList?pageNum=1');
</script>
</html>